#pragma once

#include "PngWrapper.h"
#include "Plotter.h"
#include <string>

namespace HW2
{
	struct PngPlotter : public Plotter
	{
		PngWrapper wrapper;
		int width;
		int height;
		PngPlotter(const std::string &filename, int width, int height) : wrapper(filename.c_str(), width, height), width(width), height(height)
		{
			wrapper.InitWritePng();
		}
		PngPlotter() : wrapper("D:\\SVN\\Graphics\\HW_Graphics\\test.png",200,200) {
			wrapper.InitWritePng();
			for(int x = 0; x < 200; ++x)
				for(int y = 0; y < 200; ++y)
					wrapper.SetValue(x,y,x*255+y);
			wrapper.WritePng();
		}

		virtual void fillBackground(Color c) {
			for(int x = 0; x < width; ++x)
				for(int y = 0; y < height; ++y)
					plot(x,y,0,c);
		};

		void write()
		{
			wrapper.WritePng();
		}


		virtual void plot(int x, int y, double z, Color c = Color(0,0,0), Coordinates orig = Coordinates())
		{
			wrapper.SetValue(x,y,SET_RGB((int)c.r,(int)c.g,(int)c.b));
		}

	};
}

